package com.shop.api;

import com.shop.config.R;
import com.shop.service.service.OssService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 'banxia'
 * @version 1.0
 * @description TODO
 * @date 2023/2/22 17:07
 */
@RequestMapping("/oss")
@RestController
@CrossOrigin
@Slf4j
public class OSSController {

    @Autowired
    private OssService ossService;

    //上传头像
    @PostMapping("/upload")
    public R uploadOssFile(MultipartFile file, @RequestParam("path") String path){
        log.info("==========================================");
        log.info("上传图片请求");
        log.info("==========================================");
        String url=ossService.uploadFileAvatar(file,path);
        log.info("==========================================");
        log.info("图片上传完成");
        log.info("==========================================");
        return R.ok().data("url",url);
    }

}
